/**
 *
 */
import Util;
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('imagesearch', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddImageRequest {
  categoryId?: int32(name='CategoryId', description='The category of the image. For more information, see [Category reference](https://help.aliyun.com/document_detail/179184.html).

> *   For product image search, if you specify a category for an image, the specified category prevails. If you do not specify a category for an image, the system predicts the category, and returns the prediction result in the response.
>*   For generic image search, only 88888888 may be returned for this parameter in the response regardless of whether a category is specified.', example='88888888'),
  crop?: boolean(name='Crop', description='Specifies whether to identify the subject in the image and search for images based on the subject identification result. Default value: true. Valid values:

*   true: The system identifies the subject in the image, and searches for images based on the subject identification result. The subject identification result is included in the response.
*   false: The system does not identify the subject in the image, and searches for images based on the entire image.', example='true'),
  customContent?: string(name='CustomContent', description='The user-defined content. The value can be up to 4,096 characters in length.

> If you specify this parameter, the response includes this parameter and its value. You can add text such as an image description.', example='zidingyi'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length. If an Image Search instance is purchased, you can log on to the [Image Search console](https://imagesearch.console.aliyun.com/) to view the instance. If no Image Search instance is purchased, you must purchase an instance. For more information, see [Activate Image Search](https://help.aliyun.com/document_detail/179178.html) and [Create an instance](https://help.aliyun.com/document_detail/66569.html).

> The instance name is not the instance ID.

This parameter is required.', example='demoinstance1'),
  intAttr?: int32(name='IntAttr', description='The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.', example='22'),
  intAttr2?: int32(name='IntAttr2', description='The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.', example='22'),
  intAttr3?: int32(name='IntAttr3'),
  intAttr4?: int32(name='IntAttr4'),
  picContent?: string(name='PicContent', description='The image file. The image file is encoded in Base64.

*   The file size of the image cannot exceed 4 MB.
*   The following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
*   The transmission timeout period cannot exceed 5 seconds.
*   For product and generic image searches, the length and width of the image must range from 100 pixels to 4,096 pixels.
*   The image cannot contain rotation settings.

> *   If you use SDKs to call this operation, you do not need to specify **PicContent**. The SDKs encapsulate this parameter and automatically encode its value in Base64. For more information about how to use Image Search SDK for Java, see [Java SDK](https://help.aliyun.com/document_detail/179188.html).
>*   If you use OpenAPI Explorer to call this operation, you can select only the **2019-03-25** version. If you call this operation of other versions, the value of **PicContent** cannot be encoded in Base64.

This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
  picName?: string(name='PicName', description='The name of the image. The name can be up to 512 characters in length.

> *   An image is uniquely identified by the values of ProductId and PicName.
>*   If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image.

This parameter is required.', example='2092061_1.jpg'),
  productId?: string(name='ProductId', description='The ID of the product. The ID can be up to 512 characters in length.

> A product may have multiple images.

This parameter is required.', example='2092061_1'),
  region?: string(name='Region', description='The subject area of the image, in the format of `x1,x2,y1,y2`. `x1 and y1` represent the position in the upper-left corner, in pixels. `x2 and y2` represent the position in the lower-right corner, in pixels.

> *   If you specify Region, the system searches for images based on the value of Region regardless of the value of Crop.
>*   The value of Region does not have a unit. The value is generated based on the length and width of the image. If the length and width of the image are scaled, the value of Region must be proportionally adjusted.', example='280,486,232,351'),
  strAttr?: string(name='StrAttr', description='The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

> The value cannot contain the following special characters: \\\\ ¥ $ & %', example='ss'),
  strAttr2?: string(name='StrAttr2', description='The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

> The value cannot contain the following special characters: \\\\ ¥ $ & %', example='ss'),
  strAttr3?: string(name='StrAttr3'),
  strAttr4?: string(name='StrAttr4'),
}

model AddImageAdvanceRequest {
  categoryId?: int32(name='CategoryId', description='The category of the image. For more information, see [Category reference](https://help.aliyun.com/document_detail/179184.html).

> *   For product image search, if you specify a category for an image, the specified category prevails. If you do not specify a category for an image, the system predicts the category, and returns the prediction result in the response.
>*   For generic image search, only 88888888 may be returned for this parameter in the response regardless of whether a category is specified.', example='88888888'),
  crop?: boolean(name='Crop', description='Specifies whether to identify the subject in the image and search for images based on the subject identification result. Default value: true. Valid values:

*   true: The system identifies the subject in the image, and searches for images based on the subject identification result. The subject identification result is included in the response.
*   false: The system does not identify the subject in the image, and searches for images based on the entire image.', example='true'),
  customContent?: string(name='CustomContent', description='The user-defined content. The value can be up to 4,096 characters in length.

> If you specify this parameter, the response includes this parameter and its value. You can add text such as an image description.', example='zidingyi'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length. If an Image Search instance is purchased, you can log on to the [Image Search console](https://imagesearch.console.aliyun.com/) to view the instance. If no Image Search instance is purchased, you must purchase an instance. For more information, see [Activate Image Search](https://help.aliyun.com/document_detail/179178.html) and [Create an instance](https://help.aliyun.com/document_detail/66569.html).

> The instance name is not the instance ID.

This parameter is required.', example='demoinstance1'),
  intAttr?: int32(name='IntAttr', description='The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.', example='22'),
  intAttr2?: int32(name='IntAttr2', description='The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.', example='22'),
  intAttr3?: int32(name='IntAttr3'),
  intAttr4?: int32(name='IntAttr4'),
  picContentObject?: readable(name='PicContent', description='The image file. The image file is encoded in Base64.

*   The file size of the image cannot exceed 4 MB.
*   The following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
*   The transmission timeout period cannot exceed 5 seconds.
*   For product and generic image searches, the length and width of the image must range from 100 pixels to 4,096 pixels.
*   The image cannot contain rotation settings.

> *   If you use SDKs to call this operation, you do not need to specify **PicContent**. The SDKs encapsulate this parameter and automatically encode its value in Base64. For more information about how to use Image Search SDK for Java, see [Java SDK](https://help.aliyun.com/document_detail/179188.html).
>*   If you use OpenAPI Explorer to call this operation, you can select only the **2019-03-25** version. If you call this operation of other versions, the value of **PicContent** cannot be encoded in Base64.

This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
  picName?: string(name='PicName', description='The name of the image. The name can be up to 512 characters in length.

> *   An image is uniquely identified by the values of ProductId and PicName.
>*   If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image.

This parameter is required.', example='2092061_1.jpg'),
  productId?: string(name='ProductId', description='The ID of the product. The ID can be up to 512 characters in length.

> A product may have multiple images.

This parameter is required.', example='2092061_1'),
  region?: string(name='Region', description='The subject area of the image, in the format of `x1,x2,y1,y2`. `x1 and y1` represent the position in the upper-left corner, in pixels. `x2 and y2` represent the position in the lower-right corner, in pixels.

> *   If you specify Region, the system searches for images based on the value of Region regardless of the value of Crop.
>*   The value of Region does not have a unit. The value is generated based on the length and width of the image. If the length and width of the image are scaled, the value of Region must be proportionally adjusted.', example='280,486,232,351'),
  strAttr?: string(name='StrAttr', description='The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

> The value cannot contain the following special characters: \\\\ ¥ $ & %', example='ss'),
  strAttr2?: string(name='StrAttr2', description='The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

> The value cannot contain the following special characters: \\\\ ¥ $ & %', example='ss'),
  strAttr3?: string(name='StrAttr3'),
  strAttr4?: string(name='StrAttr4'),
}

model AddImageResponseBody = {
  code?: int32(name='Code', description='The code returned.

*   A value of 0 indicates that the request was successful.
*   Values other than 0 indicate that the request failed.', example='0'),
  message?: string(name='Message', description='The error message returned if the request failed.

> No value is returned if the request was successful, and an error message is returned if the request failed.', example='success'),
  picInfo?: {
    categoryId?: int32(name='CategoryId', description='The result of category prediction. If a category is specified in the request, the specified category prevails.', example='88888888'),
    region?: string(name='Region', description='The result of subject identification. The subject area of the image is in the format of `x1,x2,y1,y2`. `x1 and y1` represent the position in the upper-left corner, in pixels. `x2 and y2` represent the position in the lower-right corner, in pixels. If a subject area is specified in the request, the specified subject area prevails.', example='94,691,206,650'),
  }(name='PicInfo', description='The results of category prediction and subject identification.'),
  requestId?: string(name='RequestId', description='The request ID.', example='E0845DE6-52AF-4B50-9F15-51ED4044E6AB'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model AddImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AddImageResponseBody(name='body'),
}

/**
 * @summary Adds an image to an Image Search instance.
 *
 * @description You can call this operation to add an image to an Image Search instance.
 * > If you want to obtain more information about the service and technical support, click [Online Consulting](https://www.aliyun.com/core/online-consult?from=aZgW6LJHr2) or join the DingTalk group (ID 35035130).
 * ## QPS limits
 * By default, the concurrency limit for adding an image to instances whose image capacity specifications are 0.1 million images is 1. This means that the system can process up to one request of adding an image every second. By default, the concurrency limit for adding an image to instances of other image capacity specifications is 5. This means that the system can process up to five requests of adding an image every second.
 *
 * @param request AddImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AddImageResponse
 */
async function addImageWithOptions(request: AddImageRequest, runtime: Util.RuntimeOptions): AddImageResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.categoryId)) {
    body['CategoryId'] = request.categoryId;
  }
  if (!Util.isUnset(request.crop)) {
    body['Crop'] = request.crop;
  }
  if (!Util.isUnset(request.customContent)) {
    body['CustomContent'] = request.customContent;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.intAttr)) {
    body['IntAttr'] = request.intAttr;
  }
  if (!Util.isUnset(request.intAttr2)) {
    body['IntAttr2'] = request.intAttr2;
  }
  if (!Util.isUnset(request.intAttr3)) {
    body['IntAttr3'] = request.intAttr3;
  }
  if (!Util.isUnset(request.intAttr4)) {
    body['IntAttr4'] = request.intAttr4;
  }
  if (!Util.isUnset(request.picContent)) {
    body['PicContent'] = request.picContent;
  }
  if (!Util.isUnset(request.picName)) {
    body['PicName'] = request.picName;
  }
  if (!Util.isUnset(request.productId)) {
    body['ProductId'] = request.productId;
  }
  if (!Util.isUnset(request.region)) {
    body['Region'] = request.region;
  }
  if (!Util.isUnset(request.strAttr)) {
    body['StrAttr'] = request.strAttr;
  }
  if (!Util.isUnset(request.strAttr2)) {
    body['StrAttr2'] = request.strAttr2;
  }
  if (!Util.isUnset(request.strAttr3)) {
    body['StrAttr3'] = request.strAttr3;
  }
  if (!Util.isUnset(request.strAttr4)) {
    body['StrAttr4'] = request.strAttr4;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddImage',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Adds an image to an Image Search instance.
 *
 * @description You can call this operation to add an image to an Image Search instance.
 * > If you want to obtain more information about the service and technical support, click [Online Consulting](https://www.aliyun.com/core/online-consult?from=aZgW6LJHr2) or join the DingTalk group (ID 35035130).
 * ## QPS limits
 * By default, the concurrency limit for adding an image to instances whose image capacity specifications are 0.1 million images is 1. This means that the system can process up to one request of adding an image every second. By default, the concurrency limit for adding an image to instances of other image capacity specifications is 5. This means that the system can process up to five requests of adding an image every second.
 *
 * @param request AddImageRequest
 * @return AddImageResponse
 */
async function addImage(request: AddImageRequest): AddImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return addImageWithOptions(request, runtime);
}

async function addImageAdvance(request: AddImageAdvanceRequest, runtime: Util.RuntimeOptions): AddImageResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'ImageSearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var addImageReq = new AddImageRequest{};
  OpenApiUtil.convert(request, addImageReq);

  if(!Util.isUnset(request.picContentObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.picContentObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    addImageReq.picContent = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var addImageResp = addImageWithOptions(addImageReq, runtime);
  return addImageResp;
}

model CompareSimilarByImageRequest {
  instanceName?: string(name='InstanceName', description='This parameter is required.', example='demoinstance1'),
  primaryPicContent?: string(name='PrimaryPicContent', description='This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
  secondaryPicContent?: string(name='SecondaryPicContent', description='This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
}

model CompareSimilarByImageAdvanceRequest {
  instanceName?: string(name='InstanceName', description='This parameter is required.', example='demoinstance1'),
  primaryPicContentObject?: readable(name='PrimaryPicContent', description='This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
  secondaryPicContentObject?: readable(name='SecondaryPicContent', description='This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
}

model CompareSimilarByImageResponseBody = {
  accessDeniedDetail?: {
    authAction?: string(name='AuthAction'),
    authPrincipalDisplayName?: string(name='AuthPrincipalDisplayName'),
    authPrincipalOwnerId?: string(name='AuthPrincipalOwnerId'),
    authPrincipalType?: string(name='AuthPrincipalType'),
    encodedDiagnosticMessage?: string(name='EncodedDiagnosticMessage'),
    noPermissionType?: string(name='NoPermissionType'),
    policyType?: string(name='PolicyType'),
  }(name='AccessDeniedDetail'),
  code?: int32(name='Code', example='0'),
  msg?: string(name='Msg', example='success'),
  requestId?: string(name='RequestId', example='B3137727-7D6E-488C-BA21-0E034C38A879'),
  score?: double(name='Score', example='0.85'),
  success?: boolean(name='Success', example='true'),
}

model CompareSimilarByImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CompareSimilarByImageResponseBody(name='body'),
}

/**
 * @summary 对比图片相似值
 *
 * @param request CompareSimilarByImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CompareSimilarByImageResponse
 */
async function compareSimilarByImageWithOptions(request: CompareSimilarByImageRequest, runtime: Util.RuntimeOptions): CompareSimilarByImageResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.primaryPicContent)) {
    body['PrimaryPicContent'] = request.primaryPicContent;
  }
  if (!Util.isUnset(request.secondaryPicContent)) {
    body['SecondaryPicContent'] = request.secondaryPicContent;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CompareSimilarByImage',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 对比图片相似值
 *
 * @param request CompareSimilarByImageRequest
 * @return CompareSimilarByImageResponse
 */
async function compareSimilarByImage(request: CompareSimilarByImageRequest): CompareSimilarByImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return compareSimilarByImageWithOptions(request, runtime);
}

async function compareSimilarByImageAdvance(request: CompareSimilarByImageAdvanceRequest, runtime: Util.RuntimeOptions): CompareSimilarByImageResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'ImageSearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var compareSimilarByImageReq = new CompareSimilarByImageRequest{};
  OpenApiUtil.convert(request, compareSimilarByImageReq);

  if(!Util.isUnset(request.primaryPicContentObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.primaryPicContentObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    compareSimilarByImageReq.primaryPicContent = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  if(!Util.isUnset(request.secondaryPicContentObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.secondaryPicContentObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    compareSimilarByImageReq.secondaryPicContent = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var compareSimilarByImageResp = compareSimilarByImageWithOptions(compareSimilarByImageReq, runtime);
  return compareSimilarByImageResp;
}

model DeleteImageRequest {
  filter?: string(name='Filter'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  isDeleteByFilter?: boolean(name='IsDeleteByFilter'),
  picName?: string(name='PicName', description='The name of the image.

*   If this parameter is not set, the system deletes all the images that correspond to the specified ProductId parameter.
*   If this parameter is set, the system deletes only the image that is specified by the ProductId and PicName parameters.', example='2092061_1.jpg'),
  productId?: string(name='ProductId', description='The ID of the commodity.

>  A commodity may have multiple images.', example='2092061_1'),
}

model DeleteImageResponseBody = {
  code?: int32(name='Code', description='The error code returned.

*   A value of 0 indicates that the operation is successful.
*   Values other than 0 indicate errors.', example='0'),
  data?: {
    picNames?: [ string ](name='PicNames', description='The name (PicName) of the deleted image.', example='5555.jpg'),
  }(name='Data', description='The information about the deleted images.'),
  message?: string(name='Message', description='The error message returned.', example='success'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='0703956F-9BCC-48FA-99F7-96C0BF449C69'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model DeleteImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteImageResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the DeleteImage operation and provides examples of this operation. You can call this operation to delete images from an Image Search instance.
 *
 * @description This operation deletes images from an Image Search instance.
 * >  A success response is returned even if the specified image does not exist on the instance. Therefore, you cannot determine whether the image exists on the instance based on the response.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 20. In this case, the system can process at most 20 requests every second.
 *
 * @param request DeleteImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteImageResponse
 */
async function deleteImageWithOptions(request: DeleteImageRequest, runtime: Util.RuntimeOptions): DeleteImageResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.filter)) {
    body['Filter'] = request.filter;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.isDeleteByFilter)) {
    body['IsDeleteByFilter'] = request.isDeleteByFilter;
  }
  if (!Util.isUnset(request.picName)) {
    body['PicName'] = request.picName;
  }
  if (!Util.isUnset(request.productId)) {
    body['ProductId'] = request.productId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteImage',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the DeleteImage operation and provides examples of this operation. You can call this operation to delete images from an Image Search instance.
 *
 * @description This operation deletes images from an Image Search instance.
 * >  A success response is returned even if the specified image does not exist on the instance. Therefore, you cannot determine whether the image exists on the instance based on the response.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 20. In this case, the system can process at most 20 requests every second.
 *
 * @param request DeleteImageRequest
 * @return DeleteImageResponse
 */
async function deleteImage(request: DeleteImageRequest): DeleteImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteImageWithOptions(request, runtime);
}

model DetailRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='imagesearchName'),
}

model DetailResponseBody = {
  instance?: {
    capacity?: int32(name='Capacity', description='The capacity of the plan. Unit: × 10,000 images.', example='10'),
    name?: string(name='Name', description='The name of the instance.', example='imagesearchName'),
    qps?: int32(name='Qps', description='The number of queries per second supported by the plan.', example='1'),
    region?: string(name='Region', description='The information about the region.', example='cn-shanghai'),
    serviceType?: int32(name='ServiceType', description='The Image Search model.

0: commodity search. 1: generic image search.', example='0'),
    totalCount?: long(name='TotalCount', description='The number of images.', example='10063'),
    utcCreate?: string(name='UtcCreate', description='The time when the instance was created. Unit: milliseconds.', example='1620382716000'),
    utcExpireTime?: string(name='UtcExpireTime', description='The time when the instance expires. Unit: milliseconds.', example='1623081600000'),
  }(name='Instance', description='The details about the instance.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='36C43E96-8F68-44AA-B1AF-B1F7AB94A6C1'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model DetailResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DetailResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the Detail operation and provides examples of this operation. You can call this operation to query instance details.
 *
 * @description This operation queries instance details.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process only 1 request every second.
 *
 * @param request DetailRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DetailResponse
 */
async function detailWithOptions(request: DetailRequest, runtime: Util.RuntimeOptions): DetailResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'Detail',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the Detail operation and provides examples of this operation. You can call this operation to query instance details.
 *
 * @description This operation queries instance details.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process only 1 request every second.
 *
 * @param request DetailRequest
 * @return DetailResponse
 */
async function detail(request: DetailRequest): DetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return detailWithOptions(request, runtime);
}

model DumpMetaRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='imagesearchName'),
}

model DumpMetaResponseBody = {
  data?: {
    dumpMetaStatus?: string(name='DumpMetaStatus', description='The status of the export task.

*   PROCESSING: in progress
*   FAIL: failed
*   SUCCESS: successful', example='PROCESSING'),
    id?: string(name='Id', description='The ID of the export task.', example='500'),
  }(name='Data', description='The information about the export task.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='36C43E96-8F68-44AA-B1AF-B1F7AB94A6C1'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model DumpMetaResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DumpMetaResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the DumpMeta operation and provides examples of this operation. You can call this operation to create a task for exporting metadata from an Image Search instance.
 *
 * @description This operation creates a task for exporting metadata from an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request DumpMetaRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DumpMetaResponse
 */
async function dumpMetaWithOptions(request: DumpMetaRequest, runtime: Util.RuntimeOptions): DumpMetaResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DumpMeta',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the DumpMeta operation and provides examples of this operation. You can call this operation to create a task for exporting metadata from an Image Search instance.
 *
 * @description This operation creates a task for exporting metadata from an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request DumpMetaRequest
 * @return DumpMetaResponse
 */
async function dumpMeta(request: DumpMetaRequest): DumpMetaResponse {
  var runtime = new Util.RuntimeOptions{};
  return dumpMetaWithOptions(request, runtime);
}

model DumpMetaListRequest {
  id?: long(name='Id', description='The ID of the export task.', example='500'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  pageNumber?: int32(name='PageNumber', description='The number of the page to return. Default value: 1.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of images to return on each page. Default value: 10.', example='10'),
}

model DumpMetaListResponseBody = {
  data?: {
    dumpMetaList?: [ 
      {
        code?: string(name='Code', description='The error code returned.

*   A value of 0 indicates that the operation is successful.
*   Values other than 0 indicate errors.', example='0'),
        id?: long(name='Id', description='The ID of the task.', example='500'),
        metaUrl?: string(name='MetaUrl', description='The address where you can download the metadata. The address is valid for 2 hours.', example='https://imagesearchname.oss-cn-shanghai.aliyuncs.com/xxx'),
        msg?: string(name='Msg', description='The error message returned.', example='success'),
        status?: string(name='Status', description='The status of the export task.

*   PROCESSING: in progress
*   FAIL: failed
*   SUCCESS: successful', example='SUCCESS'),
        utcCreate?: string(name='UtcCreate', description='The time when the task was created. Unit: milliseconds.', example='1629095713000'),
        utcModified?: long(name='UtcModified', description='The time when the task was updated. Unit: milliseconds.', example='1629095760000'),
      }
    ](name='DumpMetaList', description='A list of tasks that are used to export metadata.'),
    pageNumber?: int32(name='PageNumber', description='The number of the page to return.', example='1'),
    pageSize?: int32(name='PageSize', description='The number of entries to return on each page.', example='10'),
    totalCount?: long(name='TotalCount', description='The total number of tasks.', example='15'),
  }(name='Data', description='The information about the task that is used to export metadata.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='B3137727-7D6E-488C-BA21-0E034C38A879'),
}

model DumpMetaListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DumpMetaListResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the DumpMetaList operation and provides examples of this operation. You can call this operation to query tasks that are used for exporting metadata from an Image Search instance.
 *
 * @description This operation queries tasks that are used for exporting metadata from an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request DumpMetaListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DumpMetaListResponse
 */
async function dumpMetaListWithOptions(request: DumpMetaListRequest, runtime: Util.RuntimeOptions): DumpMetaListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.id)) {
    query['Id'] = request.id;
  }
  if (!Util.isUnset(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DumpMetaList',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the DumpMetaList operation and provides examples of this operation. You can call this operation to query tasks that are used for exporting metadata from an Image Search instance.
 *
 * @description This operation queries tasks that are used for exporting metadata from an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request DumpMetaListRequest
 * @return DumpMetaListResponse
 */
async function dumpMetaList(request: DumpMetaListRequest): DumpMetaListResponse {
  var runtime = new Util.RuntimeOptions{};
  return dumpMetaListWithOptions(request, runtime);
}

model IncreaseInstanceRequest {
  bucketName?: string(name='BucketName', description='The name of the Object Storage Service (OSS) bucket.

>  The bucket must be in the same region as the Image Search instance.

This parameter is required.', example='bucketName'),
  callbackAddress?: string(name='CallbackAddress', description='The callback address.', example='http://xxxxx'),
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='imagesearchName'),
  path?: string(name='Path', description='The absolute path to the increment.meta file in the bucket. The path must start with a forward slash (/) and cannot end with a forward slash (/).

This parameter is required.', example='/xxx/xxx'),
}

model IncreaseInstanceResponseBody = {
  data?: {
    id?: string(name='Id', description='The ID of the task.', example='500'),
    incrementStatus?: string(name='IncrementStatus', description='The status of the task.

*   PROCESSING: in progress
*   FAIL: failed
*   SUCCESS: successful', example='PROCESSING'),
  }(name='Data', description='The information about the task.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='36C43E96-8F68-44AA-B1AF-B1F7AB94A6C1'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model IncreaseInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: IncreaseInstanceResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the IncreaseInstance operation and provides examples of this operation. You can call this operation to create a batch task on an Image Search instance.
 *
 * @description This operation creates a batch task on an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request IncreaseInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return IncreaseInstanceResponse
 */
async function increaseInstanceWithOptions(request: IncreaseInstanceRequest, runtime: Util.RuntimeOptions): IncreaseInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.bucketName)) {
    query['BucketName'] = request.bucketName;
  }
  if (!Util.isUnset(request.callbackAddress)) {
    query['CallbackAddress'] = request.callbackAddress;
  }
  if (!Util.isUnset(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.path)) {
    query['Path'] = request.path;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'IncreaseInstance',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the IncreaseInstance operation and provides examples of this operation. You can call this operation to create a batch task on an Image Search instance.
 *
 * @description This operation creates a batch task on an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request IncreaseInstanceRequest
 * @return IncreaseInstanceResponse
 */
async function increaseInstance(request: IncreaseInstanceRequest): IncreaseInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return increaseInstanceWithOptions(request, runtime);
}

model IncreaseListRequest {
  bucketName?: string(name='BucketName', description='The name of the Object Storage Service (OSS) bucket.', example='bucketName'),
  id?: long(name='Id', description='The ID of the batch task.', example='500'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  pageNumber?: int32(name='PageNumber', description='The number of the page to return. Default value: 1.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of images to return on each page. Default value: 10.', example='10'),
  path?: string(name='Path', description='The absolute path to the increment.meta file in the bucket. The path must start with a forward slash (/) and cannot end with a forward slash (/).', example='/xxx/xxx'),
}

model IncreaseListResponseBody = {
  data?: {
    increments?: {
      instance?: [ 
      {
        bucketName?: string(name='BucketName', description='The name of the Object Storage Service (OSS) bucket.', example='bucketName'),
        callbackAddress?: string(name='CallbackAddress', description='The callback address.', example='http://xxxxx'),
        code?: string(name='Code', description='The error code returned.

*   A value of 0 indicates that the operation is successful.
*   Values other than 0 indicate errors.', example='0'),
        errorUrl?: string(name='ErrorUrl', description='The address where you can download the result. The address is valid for 2 hours.', example='https://imagesearchname.oss-cn-shanghai.aliyuncs.com/xxx'),
        id?: long(name='Id', description='The ID of the task.', example='500'),
        msg?: string(name='Msg', description='The error message returned.', example='sucess'),
        path?: string(name='Path', description='The absolute path to the increment.meta file in the bucket. The path must start with a forward slash (/) and cannot end with a forward slash (/).', example='/xx/xx'),
        status?: string(name='Status', description='The status of the batch task.

*   PROCESSING: in progress
*   FAIL: failed
*   SUCCESS: successful', example='SUCCESS'),
        utcCreate?: string(name='UtcCreate', description='The time when the task was created. Unit: milliseconds.', example='1629095713000'),
        utcModified?: long(name='UtcModified', description='The time when the task was updated. Unit: milliseconds.', example='1629095760000'),
      }
    ](name='Instance')
    }(name='Increments', description='A list of batch tasks.'),
    pageNumber?: int32(name='PageNumber', description='The number of the page to return.', example='1'),
    pageSize?: int32(name='PageSize', description='The number of entries to return on each page.', example='10'),
    totalCount?: long(name='TotalCount', description='The total number of tasks.', example='15'),
  }(name='Data', description='The information about the batch task.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='B3137727-7D6E-488C-BA21-0E034C38A879'),
}

model IncreaseListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: IncreaseListResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the IncreaseList operation and provides examples of this operation. You can call this operation to query batch tasks on an Image Search instance.
 *
 * @description This operation queries batch tasks on an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request IncreaseListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return IncreaseListResponse
 */
async function increaseListWithOptions(request: IncreaseListRequest, runtime: Util.RuntimeOptions): IncreaseListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.bucketName)) {
    query['BucketName'] = request.bucketName;
  }
  if (!Util.isUnset(request.id)) {
    query['Id'] = request.id;
  }
  if (!Util.isUnset(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.path)) {
    query['Path'] = request.path;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'IncreaseList',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the IncreaseList operation and provides examples of this operation. You can call this operation to query batch tasks on an Image Search instance.
 *
 * @description This operation queries batch tasks on an Image Search instance.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 1. In this case, the system can process at most 1 request every second.
 *
 * @param request IncreaseListRequest
 * @return IncreaseListResponse
 */
async function increaseList(request: IncreaseListRequest): IncreaseListResponse {
  var runtime = new Util.RuntimeOptions{};
  return increaseListWithOptions(request, runtime);
}

model SearchImageByNameRequest {
  categoryId?: int32(name='CategoryId', description='The category of the product. For more information, see [Category references](https://help.aliyun.com/document_detail/179184.html).

*   For product search: If a category is specified, the specified category prevails. If no category is specified, the system estimates and selects a category. The category selected by the system is included in the response.
*   For generic search: The parameter value is set to 88888888 regardless of whether a category is specified.', example='88888888'),
  distinctProductId?: boolean(name='DistinctProductId'),
  filter?: string(name='Filter', description='The filter conditions. int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the following operators: = and !=. You can set the logical operator between conditions to AND or OR.

Examples:

*   int_attr>=100
*   str_attr!="value1"
*   int_attr=1000 AND str_attr="value1"', example='int_attr>=100'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  num?: int32(name='Num', description='The number of images to return on each page. Valid values: 1 to 100. Default value: 10.', example='10'),
  picName?: string(name='PicName', description='The name of the image.

This parameter is required.', example='2092061_1.jpg'),
  productId?: string(name='ProductId', description='The ID of the product.

This parameter is required.', example='2092061_1'),
  start?: int32(name='Start', description='The number of the image to return. Valid values: 0 to 499. Default value: 0.', example='0'),
}

model SearchImageByNameResponseBody = {
  auctions?: [ 
    {
      categoryId?: int32(name='CategoryId', description='The category of the image.', example='20'),
      customContent?: string(name='CustomContent', description='The user-defined content.', example='zidingyi'),
      intAttr?: int32(name='IntAttr', description='The attribute, which is an integer.', example='2'),
      intAttr2?: int32(name='IntAttr2', example='20'),
      intAttr3?: int32(name='IntAttr3'),
      intAttr4?: int32(name='IntAttr4'),
      picName?: string(name='PicName', description='The name of the image.', example='2092061_1.jpg'),
      productId?: string(name='ProductId', description='The ID of the product.', example='2092061_1'),
      score?: float(name='Score', description='The similarity score of the returned image. Valid values: 0 to 1.

>  To use this feature, you must upgrade the SDK to version 3.1.1.', example='1'),
      sortExprValues?: string(name='SortExprValues', description='The score information about the image.

> *   This parameter is not supported. We recommend that you use the Score parameter.
>*   The SortExprValues parameter indicates a 2-tuple in which values are separated by a semicolon (;). The first value indicates the correlation score of the returned image. A greater value indicates a higher correlation with the sample image. Different algorithms are used.
>*   If the value of CategoryId is within the value range from 0 to 2, the value range of SortExprValues is from 0 to 7.33136443711219e+24.
>*   If the value of CategoryId is not within the value range from 0 to 2, the value range of SortExprValues is from 0 to 5.37633353624177e+24. If the returned image is identical with the sample image, the highest correlation score is generated.', example='5.37633353624177e+24;0'),
      strAttr?: string(name='StrAttr', description='The attribute, which is a string.', example='ss'),
      strAttr2?: string(name='StrAttr2', example='test'),
      strAttr3?: string(name='StrAttr3'),
      strAttr4?: string(name='StrAttr4'),
    }
  ](name='Auctions', description='The product descriptions returned.'),
  code?: int32(name='Code', description='The error code returned.

*   A value of 0 indicates that the operation is successful.
*   Values other than 0 indicate errors.', example='0'),
  head?: {
    docsFound?: int32(name='DocsFound', description='The number of images returned.', example='10'),
    docsReturn?: int32(name='DocsReturn', description='The number of images that match the search conditions on the Image Search instance.', example='10000'),
    searchTime?: int32(name='SearchTime', description='The time it takes to complete the search process. Unit: milliseconds.', example='95'),
  }(name='Head', description='The summary of the search result.'),
  msg?: string(name='Msg', description='The error message returned.', example='success'),
  picInfo?: {
    allCategories?: [ 
      {
        id?: int32(name='Id', description='The ID of the category.', example='other'),
        name?: string(name='Name', description='The name of the category.', example='88888888'),
      }
    ](name='AllCategories', description='The categories that are supported by the system.'),
    categoryId?: int32(name='CategoryId', description='The category selected by the system.

If a category is specified in the request, the specified category prevails.', example='20'),
    multiRegion?: [ 
      {
        region?: string(name='Region', description='The result of subject recognition.

The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. If a subject area is specified in the request, the specified subject area prevails.', example='280,486,232,351'),
      }
    ](name='MultiRegion', description='The recognized subjects.'),
    region?: string(name='Region', description='The result of subject recognition.

The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. If a subject area is specified in the request, the specified subject area prevails.', example='280,486,232,351'),
  }(name='PicInfo', description='The information such as the system-selected category and result of subject recognition.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='36C43E96-8F68-44AA-B1AF-B1F7AB94A6C1'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model SearchImageByNameResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SearchImageByNameResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the SearchByName operation and provides examples of this operation. You can call this operation to search for images by image name on an Image Search instance.
 *
 * @description This operation searches for images by image name on an Image Search instance.
 * ## QPS limits
 * The maximum number of queries per second is displayed in the Image Search console. The upper limit is specified when you purchase the instance. You can set the upper limit to 5 QPS or 10 QPS.
 *
 * @param request SearchImageByNameRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SearchImageByNameResponse
 */
async function searchImageByNameWithOptions(request: SearchImageByNameRequest, runtime: Util.RuntimeOptions): SearchImageByNameResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.categoryId)) {
    body['CategoryId'] = request.categoryId;
  }
  if (!Util.isUnset(request.distinctProductId)) {
    body['DistinctProductId'] = request.distinctProductId;
  }
  if (!Util.isUnset(request.filter)) {
    body['Filter'] = request.filter;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.num)) {
    body['Num'] = request.num;
  }
  if (!Util.isUnset(request.picName)) {
    body['PicName'] = request.picName;
  }
  if (!Util.isUnset(request.productId)) {
    body['ProductId'] = request.productId;
  }
  if (!Util.isUnset(request.start)) {
    body['Start'] = request.start;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SearchImageByName',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the SearchByName operation and provides examples of this operation. You can call this operation to search for images by image name on an Image Search instance.
 *
 * @description This operation searches for images by image name on an Image Search instance.
 * ## QPS limits
 * The maximum number of queries per second is displayed in the Image Search console. The upper limit is specified when you purchase the instance. You can set the upper limit to 5 QPS or 10 QPS.
 *
 * @param request SearchImageByNameRequest
 * @return SearchImageByNameResponse
 */
async function searchImageByName(request: SearchImageByNameRequest): SearchImageByNameResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchImageByNameWithOptions(request, runtime);
}

model SearchImageByPicRequest {
  categoryId?: int32(name='CategoryId', description='The category of the product. For more information, see [Category references](https://help.aliyun.com/document_detail/179184.html).

*   For product search: If a category is specified, the specified category prevails. If no category is specified, the system estimates and selects a category. The category selected by the system is included in the response.
*   For generic search: The parameter value is set to 88888888 regardless of whether a category is specified.', example='88888888'),
  crop?: boolean(name='Crop', description='Specifies whether to recognize the subject in the image and search for images based on the recognized subject. Valid values: true and false. Default value: true.

*   true: The system recognizes the subject in the image, and searches for images based on the recognized subject. The recognition result is included in the response.
*   false: The system does not recognize the subject of the image, and searches for images based on the entire image.', example='true'),
  distinctProductId?: boolean(name='DistinctProductId'),
  filter?: string(name='Filter', description='The filter conditions. int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the following operators: = and !=. You can set the logical operator between conditions to AND or OR.

Examples:

*   int_attr>=100
*   str_attr!="value1"
*   Example: int_attr=1000 AND str_attr="value1"', example='int_attr=1000 AND str_attr="value1"'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  num?: int32(name='Num', description='The number of images to return on each page. Valid values: 1 to 100. Default value: 10.', example='10'),
  picContent?: string(name='PicContent', description='The image file. The image file is encoded in Base64.

*   The file size of the image cannot exceed 4 MB.
*   The following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
*   The transmission timeout period cannot exceed 5 seconds.
*   For brand image searches, the length and the width of the image must range from 200 pixels to 4,096 pixels.
*   For cloth image searches, the length and the width of the image must range from 448 pixels to 4,096 pixels.
*   For product and generic image searches, the length and the width of the image must range from 100 pixels to 4,096 pixels.
*   The image cannot contain rotation settings.

This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
  region?: string(name='Region', description='The subject area of the image. Specify the subject area in the following format: `x1,x2,y1,y2`. `x1 and y1` represent the upper-left corner pixel. `x2 and y2` represent the lower-right corner pixel.

>*   If you set the Region parameter, the system searches for images based on the value of Region regardless of the value of the Crop parameter.', example='280,486,232,351'),
  start?: int32(name='Start', description='The number of the image to return. Valid values: 0 to 499. Default value: 0.', example='0'),
}

model SearchImageByPicAdvanceRequest {
  categoryId?: int32(name='CategoryId', description='The category of the product. For more information, see [Category references](https://help.aliyun.com/document_detail/179184.html).

*   For product search: If a category is specified, the specified category prevails. If no category is specified, the system estimates and selects a category. The category selected by the system is included in the response.
*   For generic search: The parameter value is set to 88888888 regardless of whether a category is specified.', example='88888888'),
  crop?: boolean(name='Crop', description='Specifies whether to recognize the subject in the image and search for images based on the recognized subject. Valid values: true and false. Default value: true.

*   true: The system recognizes the subject in the image, and searches for images based on the recognized subject. The recognition result is included in the response.
*   false: The system does not recognize the subject of the image, and searches for images based on the entire image.', example='true'),
  distinctProductId?: boolean(name='DistinctProductId'),
  filter?: string(name='Filter', description='The filter conditions. int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the following operators: = and !=. You can set the logical operator between conditions to AND or OR.

Examples:

*   int_attr>=100
*   str_attr!="value1"
*   Example: int_attr=1000 AND str_attr="value1"', example='int_attr=1000 AND str_attr="value1"'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  num?: int32(name='Num', description='The number of images to return on each page. Valid values: 1 to 100. Default value: 10.', example='10'),
  picContentObject?: readable(name='PicContent', description='The image file. The image file is encoded in Base64.

*   The file size of the image cannot exceed 4 MB.
*   The following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
*   The transmission timeout period cannot exceed 5 seconds.
*   For brand image searches, the length and the width of the image must range from 200 pixels to 4,096 pixels.
*   For cloth image searches, the length and the width of the image must range from 448 pixels to 4,096 pixels.
*   For product and generic image searches, the length and the width of the image must range from 100 pixels to 4,096 pixels.
*   The image cannot contain rotation settings.

This parameter is required.', example='AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII='),
  region?: string(name='Region', description='The subject area of the image. Specify the subject area in the following format: `x1,x2,y1,y2`. `x1 and y1` represent the upper-left corner pixel. `x2 and y2` represent the lower-right corner pixel.

>*   If you set the Region parameter, the system searches for images based on the value of Region regardless of the value of the Crop parameter.', example='280,486,232,351'),
  start?: int32(name='Start', description='The number of the image to return. Valid values: 0 to 499. Default value: 0.', example='0'),
}

model SearchImageByPicResponseBody = {
  auctions?: [ 
    {
      categoryId?: int32(name='CategoryId', description='The category of the image.', example='8888888'),
      customContent?: string(name='CustomContent', description='The user-defined content.', example='zidingyi'),
      intAttr?: int32(name='IntAttr', description='The attribute, which is an integer.', example='2'),
      intAttr2?: int32(name='IntAttr2', example='20'),
      intAttr3?: int32(name='IntAttr3'),
      intAttr4?: int32(name='IntAttr4'),
      picName?: string(name='PicName', description='The name of the image.', example='2092061_1.jpg'),
      productId?: string(name='ProductId', description='The ID of the product.', example='2092061_1'),
      score?: float(name='Score', description='The similarity score of the searched image. Valid values: 0 to 1.

>  To use this feature, you must upgrade the SDK to version 3.1.1.', example='1'),
      sortExprValues?: string(name='SortExprValues', description='The score information about the image.

> *   This parameter is not supported. We recommend that you use the Score parameter.
>*   The SortExprValues parameter indicates a 2-tuple in which values are separated by a semicolon (;). The first value indicates the correlation score of the returned image. A greater value indicates a higher correlation with the sample image. Different algorithms are used.
>*   If the value of CategoryId is within the value range from 0 to 2, the value range of SortExprValues is from 0 to 7.33136443711219e+24.
>*   If the value of CategoryId is not within the value range from 0 to 2, the value range of SortExprValues is from 0 to 5.37633353624177e+24. If the returned image is identical with the sample image, the highest correlation score is generated.', example='5.37633353624177e+24;0'),
      strAttr?: string(name='StrAttr', description='The attribute, which is a string.', example='2'),
      strAttr2?: string(name='StrAttr2', example='test'),
      strAttr3?: string(name='StrAttr3'),
      strAttr4?: string(name='StrAttr4'),
    }
  ](name='Auctions', description='The product descriptions returned.'),
  code?: int32(name='Code', description='The error code returned.

*   A value of 0 indicates that the operation is successful.
*   Values other than 0 indicate errors.', example='0'),
  head?: {
    docsFound?: int32(name='DocsFound', description='The number of images returned.', example='10'),
    docsReturn?: int32(name='DocsReturn', description='The number of images that match the search conditions on the Image Search instance.', example='10000'),
    searchTime?: int32(name='SearchTime', description='The time it takes to complete the search process. Unit: milliseconds.', example='95'),
  }(name='Head', description='The summary of the search result.'),
  msg?: string(name='Msg', description='The error message returned.', example='success'),
  picInfo?: {
    allCategories?: [ 
      {
        id?: int32(name='Id', description='The ID of the category.', example='88888888'),
        name?: string(name='Name', description='The name of the category.', example='other'),
      }
    ](name='AllCategories', description='The categories that are supported by the system.'),
    categoryId?: int32(name='CategoryId', description='The category selected by the system. If a category is specified in the request, the specified category prevails.', example='88888888'),
    multiRegion?: [ 
      {
        region?: string(name='Region', description='The result of subject recognition. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. If a subject area is specified in the request, the specified subject area prevails.', example='280,486,232,351'),
      }
    ](name='MultiRegion', description='The recognized subjects.

>  To use this feature, you must upgrade the SDK to version 3.1.1.'),
    region?: string(name='Region', description='The result of subject recognition. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. If a subject area is specified in the request, the specified subject area prevails.', example='280,486,232,351'),
  }(name='PicInfo', description='The information such as the system-selected category and result of subject recognition.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='B3137727-7D6E-488C-BA21-0E034C38A879'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model SearchImageByPicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SearchImageByPicResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the SearchByPic operation and provides examples of this operation. You can call this operation to search for images by image on an Image Search Instance.
 *
 * @description This operation searches for images by image name on an Image Search instance.
 * ## QPS limits
 * The maximum number of queries per second is displayed in the Image Search console. The upper limit is specified when you purchase the instance. You can set the upper limit to 5 QPS or 10 QPS.  
 * ## SDK release notes
 * The Image Search SDK has been upgraded to version 3.1.1, which supports multi-subject recognition and similarity scores. For more information, see [Image Search SDK for Java](/help/en/image-search/latest/version-v3-java-sdk).
 *
 * @param request SearchImageByPicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SearchImageByPicResponse
 */
async function searchImageByPicWithOptions(request: SearchImageByPicRequest, runtime: Util.RuntimeOptions): SearchImageByPicResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.categoryId)) {
    body['CategoryId'] = request.categoryId;
  }
  if (!Util.isUnset(request.crop)) {
    body['Crop'] = request.crop;
  }
  if (!Util.isUnset(request.distinctProductId)) {
    body['DistinctProductId'] = request.distinctProductId;
  }
  if (!Util.isUnset(request.filter)) {
    body['Filter'] = request.filter;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.num)) {
    body['Num'] = request.num;
  }
  if (!Util.isUnset(request.picContent)) {
    body['PicContent'] = request.picContent;
  }
  if (!Util.isUnset(request.region)) {
    body['Region'] = request.region;
  }
  if (!Util.isUnset(request.start)) {
    body['Start'] = request.start;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SearchImageByPic',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the SearchByPic operation and provides examples of this operation. You can call this operation to search for images by image on an Image Search Instance.
 *
 * @description This operation searches for images by image name on an Image Search instance.
 * ## QPS limits
 * The maximum number of queries per second is displayed in the Image Search console. The upper limit is specified when you purchase the instance. You can set the upper limit to 5 QPS or 10 QPS.  
 * ## SDK release notes
 * The Image Search SDK has been upgraded to version 3.1.1, which supports multi-subject recognition and similarity scores. For more information, see [Image Search SDK for Java](/help/en/image-search/latest/version-v3-java-sdk).
 *
 * @param request SearchImageByPicRequest
 * @return SearchImageByPicResponse
 */
async function searchImageByPic(request: SearchImageByPicRequest): SearchImageByPicResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchImageByPicWithOptions(request, runtime);
}

async function searchImageByPicAdvance(request: SearchImageByPicAdvanceRequest, runtime: Util.RuntimeOptions): SearchImageByPicResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'ImageSearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var searchImageByPicReq = new SearchImageByPicRequest{};
  OpenApiUtil.convert(request, searchImageByPicReq);

  if(!Util.isUnset(request.picContentObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.picContentObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    searchImageByPicReq.picContent = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var searchImageByPicResp = searchImageByPicWithOptions(searchImageByPicReq, runtime);
  return searchImageByPicResp;
}

model SearchImageByTextRequest {
  distinctProductId?: boolean(name='DistinctProductId', example='false'),
  filter?: string(name='Filter', example='int_attr=1000 AND str_attr="value1"'),
  instanceName?: string(name='InstanceName', description='This parameter is required.', example='demoinstance1'),
  num?: int32(name='Num', example='10'),
  start?: int32(name='Start', example='0'),
  text?: string(name='Text', description='This parameter is required.', example='xxxx'),
}

model SearchImageByTextResponseBody = {
  accessDeniedDetail?: {
    authAction?: string(name='AuthAction', example='xxx'),
    authPrincipalDisplayName?: string(name='AuthPrincipalDisplayName', example='111'),
    authPrincipalOwnerId?: string(name='AuthPrincipalOwnerId', example='222'),
    authPrincipalType?: string(name='AuthPrincipalType', example='SubUser'),
    encodedDiagnosticMessage?: string(name='EncodedDiagnosticMessage', example='xxxxxx'),
    noPermissionType?: string(name='NoPermissionType', example='ImplicitDeny'),
    policyType?: string(name='PolicyType', example='PauseNotify'),
  }(name='AccessDeniedDetail'),
  auctions?: [ 
    {
      categoryId?: int32(name='CategoryId', example='8888888'),
      customContent?: string(name='CustomContent', example='zidingyi'),
      intAttr?: int32(name='IntAttr', example='2'),
      intAttr2?: int32(name='IntAttr2', example='2'),
      intAttr3?: int32(name='IntAttr3', example='2'),
      intAttr4?: int32(name='IntAttr4', example='2'),
      picName?: string(name='PicName', example='2092061_1.jpg'),
      productId?: string(name='ProductId', example='2092061_1'),
      score?: float(name='Score', example='1'),
      strAttr?: string(name='StrAttr', example='xxxx'),
      strAttr2?: string(name='StrAttr2', example='xxxx'),
      strAttr3?: string(name='StrAttr3', example='xxxx'),
      strAttr4?: string(name='StrAttr4', example='xxxx'),
    }
  ](name='Auctions'),
  code?: int32(name='Code', example='0'),
  head?: {
    docsFound?: int32(name='DocsFound', example='10'),
    docsReturn?: int32(name='DocsReturn', example='10000'),
    searchTime?: int32(name='SearchTime', example='95'),
  }(name='Head'),
  msg?: string(name='Msg', example='success'),
  picInfo?: {
    allCategories?: [ 
      {
        id?: int32(name='Id', example='88888888'),
        name?: string(name='Name', example='other'),
      }
    ](name='AllCategories'),
  }(name='PicInfo'),
  requestId?: string(name='RequestId', example='B3137727-7D6E-488C-BA21-0E034C38A879'),
  success?: boolean(name='Success', example='true'),
}

model SearchImageByTextResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SearchImageByTextResponseBody(name='body'),
}

/**
 * @summary SearchImageByText
 *
 * @param request SearchImageByTextRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SearchImageByTextResponse
 */
async function searchImageByTextWithOptions(request: SearchImageByTextRequest, runtime: Util.RuntimeOptions): SearchImageByTextResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.distinctProductId)) {
    body['DistinctProductId'] = request.distinctProductId;
  }
  if (!Util.isUnset(request.filter)) {
    body['Filter'] = request.filter;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.num)) {
    body['Num'] = request.num;
  }
  if (!Util.isUnset(request.start)) {
    body['Start'] = request.start;
  }
  if (!Util.isUnset(request.text)) {
    body['Text'] = request.text;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SearchImageByText',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary SearchImageByText
 *
 * @param request SearchImageByTextRequest
 * @return SearchImageByTextResponse
 */
async function searchImageByText(request: SearchImageByTextRequest): SearchImageByTextResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchImageByTextWithOptions(request, runtime);
}

model UpdateImageRequest {
  customContent?: string(name='CustomContent', description='The user-defined content. The value can be up to 4,096 characters in length.

>  If you set this parameter, the response includes this parameter and its value. You can add text such as an image description.', example='zidingyi'),
  instanceName?: string(name='InstanceName', description='The name of the Image Search instance. The name can be up to 20 characters in length.

This parameter is required.', example='demoinstance1'),
  intAttr?: int32(name='IntAttr', description='The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you set this parameter, the response includes this parameter and its value.', example='2'),
  intAttr2?: int32(name='IntAttr2', example='20'),
  intAttr3?: int32(name='IntAttr3'),
  intAttr4?: int32(name='IntAttr4'),
  picName?: string(name='PicName', description='The name of the image. The name can be up to 512 characters in length.

> *   An image is uniquely identified by the values of the ProductId and PicName parameters.
>*   If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image.

This parameter is required.', example='namexxx.jpg'),
  productId?: string(name='ProductId', description='The ID of the product. The ID can be up to 512 characters in length.

>  A product may have multiple images.

This parameter is required.', example='2092061_1'),
  strAttr?: string(name='StrAttr', description='The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images. If you set this parameter, the response includes this parameter and its value.', example='ss'),
  strAttr2?: string(name='StrAttr2', example='test'),
  strAttr3?: string(name='StrAttr3'),
  strAttr4?: string(name='StrAttr4'),
}

model UpdateImageResponseBody = {
  code?: int32(name='Code', description='The error code returned.

*   A value of 0 indicates that the operation is successful.
*   Values other than 0 indicate errors.', example='0'),
  message?: string(name='Message', description='Id of the request', example='success'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='E0845DE6-52AF-4B50-9F15-51ED4044E6AB'),
  success?: boolean(name='Success', description='Indicates whether the request is successful.', example='true'),
}

model UpdateImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateImageResponseBody(name='body'),
}

/**
 * @summary This topic describes the syntax of the UpdateImage operation and provides examples of this operation. You can call this operation to update image information on an Image Search instance.
 *
 * @description This operation updates image information on an Image Search instance.
 * > *   Limits are imposed on the instance creation time.
 * >*   This operation is supported by instances that are created in the Singapore (Singapore) region after December 2021. This operation is not supported in other regions.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 20. In this case, the system can process at most 20 requests every second.
 *
 * @param request UpdateImageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateImageResponse
 */
async function updateImageWithOptions(request: UpdateImageRequest, runtime: Util.RuntimeOptions): UpdateImageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.intAttr3)) {
    query['IntAttr3'] = request.intAttr3;
  }
  if (!Util.isUnset(request.intAttr4)) {
    query['IntAttr4'] = request.intAttr4;
  }
  if (!Util.isUnset(request.strAttr3)) {
    query['StrAttr3'] = request.strAttr3;
  }
  if (!Util.isUnset(request.strAttr4)) {
    query['StrAttr4'] = request.strAttr4;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.customContent)) {
    body['CustomContent'] = request.customContent;
  }
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.intAttr)) {
    body['IntAttr'] = request.intAttr;
  }
  if (!Util.isUnset(request.intAttr2)) {
    body['IntAttr2'] = request.intAttr2;
  }
  if (!Util.isUnset(request.picName)) {
    body['PicName'] = request.picName;
  }
  if (!Util.isUnset(request.productId)) {
    body['ProductId'] = request.productId;
  }
  if (!Util.isUnset(request.strAttr)) {
    body['StrAttr'] = request.strAttr;
  }
  if (!Util.isUnset(request.strAttr2)) {
    body['StrAttr2'] = request.strAttr2;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateImage',
    version = '2020-12-14',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary This topic describes the syntax of the UpdateImage operation and provides examples of this operation. You can call this operation to update image information on an Image Search instance.
 *
 * @description This operation updates image information on an Image Search instance.
 * > *   Limits are imposed on the instance creation time.
 * >*   This operation is supported by instances that are created in the Singapore (Singapore) region after December 2021. This operation is not supported in other regions.
 * ## QPS limits
 * By default, the maximum number of queries supported by this operation is 20. In this case, the system can process at most 20 requests every second.
 *
 * @param request UpdateImageRequest
 * @return UpdateImageResponse
 */
async function updateImage(request: UpdateImageRequest): UpdateImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateImageWithOptions(request, runtime);
}

